Introduction

您所在的位置:网站首页 bash python Introduction

Introduction

2024-07-03 11:22| 来源: 网络整理| 查看: 265

Unlike development environments, where making use of the latest tools is desirable, in a CI environment reproducibility should be made the priority. Here are some suggestions for installing Poetry in such an environment.

Version pinning

Whatever method you use, it is highly recommended to explicitly control the version of Poetry used, so that you are able to upgrade after performing your own validation. Each install method has a different syntax for setting the version that is used in the following examples.

Using pipx

Just as pipx is a powerful tool for development use, it is equally useful in a CI environment and should be one of your top choices for use of Poetry in CI.

pipx install poetry==1.2.0

Using install.python-poetry.org

Note The official installer script (install.python-poetry.org) offers a streamlined and simplified installation of Poetry, sufficient for developer use or for simple pipelines. However, in a CI environment the other two supported installation methods (pipx and manual) should be seriously considered.

Downloading a copy of the installer script to a place accessible by your CI pipelines (or maintaining a copy of the repository) is strongly suggested, to ensure your pipeline’s stability and to maintain control over what code is executed.

By default, the installer will install to a user-specific directory. In more complex pipelines that may make accessing Poetry difficult (especially in cases like multi-stage container builds). It is highly suggested to make use of $POETRY_HOME when using the official installer in CI, as that way the exact paths can be controlled.

export POETRY_HOME=/opt/poetry python3 install-poetry.py --version 1.2.0 $POETRY_HOME/bin/poetry --version

Using pip (aka manually)

For maximum control in your CI environment, installation with pip is fully supported and something you should consider. While this requires more explicit commands and knowledge of Python packaging from you, it in return offers the best debugging experience, and leaves you subject to the fewest external tools.

export POETRY_HOME=/opt/poetry python3 -m venv $POETRY_HOME $POETRY_HOME/bin/pip install poetry==1.2.0 $POETRY_HOME/bin/poetry --version Note If you install Poetry via pip, ensure you have Poetry installed into an isolated environment that is not the same as the target environment managed by Poetry. If Poetry and your project are installed into the same environment, Poetry is likely to upgrade or uninstall its own dependencies (causing hard-to-debug and understand errors).


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3